<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Canvas</title>
    <style></style>
  </head>
  <body>
    <div class="container">
      <canvas id="demo"></canvas>
    </div>
    <script src="./useMyRect.js"></script>
    <script>
      ;(function () {
        const $canvas = document.querySelector('#demo')
        $canvas.width = 600
        $canvas.height = 600
        $canvas.style.border = '1px solid #cccccc'

        const context = $canvas.getContext('2d')

        const tt = new MyRect({
          width: 100,
          height: 100,
          translateX: 10,
          translateY: 100,
        })

        setInterval(() => {
          context.clearRect(0, 0, $canvas.width, $canvas.height)
          tt.translateX += 10
          tt.render(context)
        }, 500)
      })()
    </script>
  </body>
</html>
